<template>
	<view class="content-display__wrapper">
		<view class="content-display" v-for="(item, index) in list" :key="index">
			<view class="content-header" @tap="toggleShow(index)">
				<view class="header-info">
					<view class="header-title">
						<text class="one-line">{{item.title}}</text>
						<view class="title-icon" :class="item.isShow?'show-icon':''">
							<uni-icons type="down" color="#fff" size="10"></uni-icons>
							<!-- <text class="cuIcon-triangledownfill text-white"></text> -->
						</view>
					</view>
					<text class="one-line" style="font-size: 28rpx;">{{item.des}}</text>
				</view>
				<image class="header-image" :src="item.image" mode="scaleToFill"></image>
			</view>
			<view class="content-body" :style="{height:item.isShow?'':'0rpx'}">
				<view class="body-animation__wrapper" :class="item.isShow?'body-show':''">
					<!-- <image class="content-img" :src="item.longimg" mode="widthFix"></image> -->
					<!-- <text>{{item.content}}</text> -->
					<uParse :domain="baseUrl" :html="item.conten" :tag-style="tagStyle"></uParse>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/jyf-parser/jyf-parser';
	import { BASE_URL } from '@/common/api/auth';
	export default {
		components: {
			uParse
		},
		props: {
			data: {
				type: Array,
				default: () => [{}]
			}
		},
		data() {
			return {
				baseUrl: BASE_URL,
				list: [],
				tagStyle: {
					img: 'width:100%;display:block;',
					table: 'width:100%',
					video: 'width:100%'
				},
			}
		},
		created() {
			this.list = this.data
			this.init()
		},
		methods: {
			init() {
				this.list.forEach(item => {
					this.$set(item, 'isShow', false)
				})
				console.log(this.list)
			},
			toggleShow(index) {
				this.$set(this.list[index], 'isShow', !this.list[index].isShow)
			}
		}
	}
</script>

<style scoped>
	.content-display__wrapper {
		/* margin: 20rpx; */
		/* padding: 16rpx; */
		/* background-color: #fff; */
		border-radius: 20rpx;
	}
	.content-display {
		margin: 30rpx;
		/* background: linear-gradient(180deg, #FFF9F5 0%, #FFFFFF 69.79%); */
		box-shadow: 4rpx 4rpx 8rpx 6rpx rgba(0, 0, 0, 0.1);
		border-radius: 24rpx;
	}
	.content-header {
		display: flex;
		justify-content: space-between;
		padding: 30rpx;
	}
	.header-info {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	.header-title {
		display: flex;
		align-items: center;
		font-size: 32rpx;
		margin-bottom: 16rpx;
	}
	.title-icon {
		display: inline-block;
		width: 30rpx;
		height: 30rpx;
		line-height: 30rpx;
		border-radius: 50%;
		background-color: #000;
		text-align: center;
		margin-left: 30rpx;
		transition: all .25s ease-in-out;
	}
	.title-icon.show-icon {
		transform: rotate(180deg);
	}
	.header-image {
		width: 100rpx;
		height: 100rpx;
		border-radius: 12rpx;
		flex-shrink: 0;
		margin-left: 30rpx;
	}
	.content-body {
		overflow: hidden;
	}
	.one-line {
		/* flex: 1; */
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.body-animation__wrapper {
		padding: 20rpx 30rpx;
		transform: translateY(-100%);
		transition: all .25s ease-in;
	}
	.body-animation__wrapper.body-show {
		transform: translateY(0%);
	}
	.content-img {
		width: 100%;
		height: auto;
	}
</style>